<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Catgory extends Migrator {

    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change() {
        // create the table 新增分类表
        $table = $this->table('catgory', array('engine' => 'MyISAM'));
        $table->addColumn('catgory_name', 'string', array('limit' => 15, 'default' => '', 'comment' => '分类名称'))
                ->addColumn('parent_id', 'integer', array('limit' => 15, 'default' => '0', 'comment' => '上级分类'))
                ->addColumn('desc', 'string', array('limit' => 32, 'default' => "", 'comment' => '描述'))
                ->create();
        // create the table 新增物品表
        $table = $this->table('goods', array('engine' => 'MyISAM'));
        $table->addColumn('goods_name', 'string', array('limit' => 15, 'default' => '', 'comment' => '物品名称'))
                ->addColumn('cate_id', 'integer', array('limit' => 15, 'default' => "0", 'comment' => '分类ID'))
                ->addColumn('quantity', 'integer', array('limit' => 15, 'default' => "0", 'comment' => '数量'))
                ->addColumn('area', 'integer', array('limit' => 32, 'default' => '0', 'comment' => '所在库位'))
                ->create();
    }

}
